package com.ruoyi.module.task;


import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.module.privateaccount.domain.BizPrivateAccount;
import com.ruoyi.module.privateaccount.service.IBizPrivateAccountService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;

import javax.annotation.Resource;

/**
 * 产品返利定时任务
 *
 * @author zhaoxi
 * @date 2023-09-13
 */
@Component("productRebateTask")
public class ProductRebateTask {
    private static final Logger LOGGER = LoggerFactory.getLogger(ProductRebateTask.class);

    @Resource
    IBizPrivateAccountService privateAccountService;

    @Scheduled(cron = "0 0 0 * * ? ")
    @GetMapping("/productRebate")
    public AjaxResult productRebate() {
        try {
            LOGGER.info("产品返利定时任务开始");
            BizPrivateAccount bizPrivateAccount = new BizPrivateAccount();
            return privateAccountService.productRebate(bizPrivateAccount);
        } catch (Exception e) {
            LOGGER.error("产品返利定时任务处理失败",e);
            return AjaxResult.error();
        }
    }
}
